/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.logical.allhit.gui.action;

import com.logical.allhit.gui.MainFrom;
import java.awt.Event;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;

/**
 *
 * @author Sanjeet Jha
 */
public class SelectAllAction extends AbstractAction {

    private MainFrom mainFrom;

    public SelectAllAction(MainFrom mainFrom) {
        putValue(NAME, bundle.getString("selectall.name"));
        putValue(SHORT_DESCRIPTION, bundle.getString("selectall.shortdis"));
        putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_1, Event.CTRL_MASK));
        putValue(SELECTED_KEY, false);
        this.mainFrom = mainFrom;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (!(Boolean)getValue(SELECTED_KEY)) {
            mainFrom.getAccountTableModel().selectAll(true);
            putValue(NAME, bundle.getString("deselectall.name"));
            putValue(SHORT_DESCRIPTION, bundle.getString("deselectall.shortdis"));
            putValue(SELECTED_KEY, true);
        } else {
            mainFrom.getAccountTableModel().selectAll(false);
            putValue(NAME, bundle.getString("selectall.name"));
            putValue(SHORT_DESCRIPTION, bundle.getString("selectall.shortdis"));
            putValue(SELECTED_KEY, false);
        }

    }
}
